﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Yang.DataBase;

/// <summary>
/// BaseClass 的摘要说明
/// </summary>
public class BaseClass
{
	public BaseClass()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    /// <summary>
    /// 定义地图显示范围
    /// </summary>
    public class MapExtent
    {
        private double _dLeft;
        private double _dTop;
        private double _dRight;
        private double _dBottom;

        public MapExtent()
        {
            _dTop = 0.0;
            _dLeft = 0.0;
            _dRight = 0.0;
            _dBottom = 0.0;
        }
        public MapExtent(double dLeft, double dBottom, double dRight, double dTop)
        {
            _dLeft = dLeft;
            _dTop = dTop;
            _dRight = dRight;
            _dBottom = dBottom;
        }
        public double Top
        {
            set
            {
                _dTop = value;
            }
            get
            {
                return _dTop;
            }
        }
        public double Left
        {
            set
            {
                _dLeft = value;
            }
            get
            {
                return _dLeft;
            }
        }
        public double Right
        {
            set
            {
                _dRight = value;
            }
            get
            {
                return _dRight;
            }
        }
        public double Bottom
        {
            set
            {
                _dBottom = value;
            }
            get
            {
                return _dBottom;
            }
        }
    }
}


public class AgriMachine
{
    private string  _deviceCode;
    private double  _lat;
    private double  _lon;
    private string  _jobCode;
    private AgriMachineWork _currentWork;
    private AgriMachineWork[] _todayWorks;
    private AgriMachineWork[] _thisQuarterWorks;

    public AgriMachine()
    {
    }

    public string DeviceCode
    {
        get { return _deviceCode; }
        set { _deviceCode = value; }
    }

    public double Lat
    {
        get { return _lat ; }
        set { _lat = value; }
    }

    public double Lon
    {
        get { return _lon ; }
        set { _lon = value; }
    }

    public string JobCode
    {
        get { return _jobCode; }
        set { _jobCode = value; }
    }
}

public class AgriMachineWork
{
    private int _workCode;
    private string _workName;
    private double _workArea;
    private double _workAmount;
    private double _workMoney;
    private double _workRatio;
    private double _workPrice;

    public AgriMachineWork()
    {
        this.WorkCode = 0;
        this.WorkName = "无作业";
        this.WorkRatio = 0.0;
        this.WorkPrice = 0.0;
        this.WorkArea =0.0;
        this.WorkAmount =0.0;
        this.WorkMoney =0.0;

    }

    public int WorkCode
    {
        get { return _workCode; }
        set { _workCode = value; }
    }

    public string  WorkName
    {
        get { return _workName; }
        set { _workName = value; }
    }

    public double WorkArea
    {
        get { return _workArea; }
        set { _workArea = value; }
    }

    public double WorkAmount
    {
        get { return Math.Round(_workArea * _workRatio / 666.67, 2); }
        set { _workAmount = value; }
    }

    public double WorkMoney
    {
        get { return Math.Round(_workArea * _workRatio * _workPrice / 666.67, 2); }
        set { _workMoney = value; }
    }

    public double WorkRatio
    {
        get { return _workRatio; }
        set { _workRatio = value; }
    }

    public double WorkPrice
    {
        get { return _workPrice; }
        set { _workPrice = value; }
    }

    public void setWorkPriceAndRatio(int WorkCode)
    {
        string strSql = "select 金额,折合系数 from 作业种类 where 作业编码 = '" + WorkCode + "'";
        DataSet ds = Database.Query(strSql);
        if (ds.Tables[0].Rows.Count == 1)
        {
            this.WorkPrice = double.Parse(ds.Tables[0].Rows[0][0].ToString());
            this.WorkRatio = double.Parse(ds.Tables[0].Rows[0][1].ToString());
        }
        else
        {
            this.WorkPrice = 0.0;
            this.WorkRatio = 0.0;
        }
    }

    //public double setWorkAmount(double workArea)
    //{
    //    return this.WorkArea * this.WorkRatio;
    //}


}